<template>
	<view class="body">
		<xk-header title="巡查详情"></xk-header>

		<view class="step-info">
			<view class="title">
				<view>
					巡查路线
				</view>
				<view class="right-title">
					共<view style="margin: 0 6rpx;color: #2C72FF;">{{Object.keys(dets).length}}</view>个巡查点
				</view>
			</view>
			<view class="tab-view">
				<scroll-view id="tab-bar" class="scroll-h" :scroll-x="true" :show-scrollbar="false" :scroll-into-view="scrollInto">
					<view class="step-view">
						<view class="steps">
							<view class="step-item" v-for="(item, key) of dets" :id="'DETS_' + key" :key="key">
								<view key="aline" class="line line-a"></view>
								<!-- <view v-else class="line" key="line"></view> -->
								<!-- <image class="icon" v-if="!item.isCheckAll" src="/static/xj-doning.png"></image> -->
								<image class="icon" :src="(imgUrl+'/wx/xj-ok.png')"></image>
								<image class="icon" :src="(imgUrl+'/wx/xj-ok.png')"></image>
								<view v-if="tabIndex + 1 == item.num" class="num num-a num-show" >{{item.num}}</view>
								<view v-else class="num num-a" >{{item.num}}</view>
								<view class="addr">{{item.building}}栋{{item.storey}}层</view>
								<view class="addr2">{{item.room || '-'}}号</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>

		<swiper :current="tabIndex" class="list-swiper"
			@change="(e)=>{tabIndex = e.target.current}"
			:style="'height:'+scrollViewHeight+'px'"
			>
			<swiper-item v-for="(tabItem, key) of dets" :key="key">
				<scroll-view refresher-background="#F8F8F8"  scroll-y :style="'height:'+scrollViewHeight+'px'">
					<view v-if="tabItem.data.length > 0" class="list-info">
						<view v-for="(item,index) of tabItem.data" :key="index" class="data-list">
							<view class="data-item">
								<view class="order-info">
									<view class="info-item"><view class="key">巡检内容：</view>{{item.partorls_content}}</view>
									<view class="info-item"><view class="key">是否正常：</view>
										<text v-if="item.is_normal == '1'" style="color: #4cd964">是</text>
										<text v-if="item.is_normal == '0'" style="color: #FF3737">否</text>
									</view>
									<view v-if="item.abnormal_content" class="info-item"><view class="key">异常描述：</view>{{item.abnormal_content}}</view>
									<view class="info-item"><view class="key"></view>
										<image-list :pics="item.patrol_image"></image-list>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="empty-view" v-else>
						<image class="empty-icon" :src="(imgUrl+'/wx/empty_data_icon.png')"></image>
						<view>哎呀，该界面暂无内容~</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl:this.$config.BASE_imgUrl,
				dets: {},

				scrollInto: '',
				triggered: false,
				tabIndex: 0,
				tabBars: [1,2,3,4,5,6,7,8],
				scrollViewHeight: 0,
			}
		},
		onLoad(options){
			this.dets = JSON.parse(options.dets)
		},

		mounted(){
			this.$util.getHeightWithTopEl(".step-info").then(height => {
				this.scrollViewHeight = height;
			});
		},
		methods: {

			switchTab(index) {
			    if (this.tabIndex === index) {
			        return;
			    }
			    this.tabIndex = index;
				if(index > 3){
					this.scrollInto = 'TAB_' + (index-3) + '';
				}else{
					this.scrollInto = 'TAB_' + 0 + '';
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.step-info{
	background-color: #FFFFFF;
	padding: 20rpx 30rpx;
	margin-top: 20rpx;
	.title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 32rpx;
		margin-bottom: 20rpx;
		font-weight: bolder;
		color: #333333;
		.right-title{
			display: flex;
			margin-left: 20rpx;
			font-size: 28rpx;
			font-weight: normal;
			color: #999999;
		}
	}
	.tab-view{
		display: flex;
		width: 690rpx;
		margin: 10rpx 0 0;
		border-radius: 20rpx;
		.scroll-h {
			width: 690rpx;
			height: 130rpx;
			flex-direction: row;
			white-space: nowrap;
		}
		.step-view{
			.steps{
				display: inline-flex;
				.step-item{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					margin: 0 30rpx;
					position: relative;
					.icon{
						width: 20rpx;
						height: 20rpx;
						position: absolute;
						top: 0;
						right: 10rpx;
						z-index: 3;
					}
					.line{
						position: absolute;
						top: 25rpx;
						left: -80rpx;
						height: 6rpx;
						width: 100rpx;
						background-color: #F9F9F9;
					}
					.line-a{
						background-color: rgba($color: #2C72FF, $alpha: 0.8);
					}
					.num{
						width: 50rpx;
						height: 50rpx;
						border-radius: 50rpx;
						font-size: 24rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						background-color: #F9F9F9;
						color: #333333;
						margin-bottom: 10rpx;
						position: relative;
						z-index: 2;
					}
					.num-a{
						color: #FFFFFF;
						background-color: rgba($color: #2C72FF, $alpha: 0.8);

					}
					.num-show{
						background-color: #2C72FF;
					}
					.addr{
						font-size: 24rpx;
						color: #333333;
					}
					.addr2{
						font-size: 24rpx;
						color: #999999;
					}
				}
				.step-item:first-child{
					margin-left: 0rpx;
					.line{
						width: 0;
					}
				}
				.step-item:last-child{
					margin-right: 0rpx;
				}
			}
		}

		// .uni-tab-item {
		// 	display: inline-flex;
		// 	align-items: center;
		// 	height: 100rpx;
		// 	position: relative;
		// 	flex-wrap: nowrap;
		// 	margin: 0 22rpx;
		// 	// padding-right: 22rpx;
		// }
		// .tab-border{
		// 	position: absolute;
		// 	left:0;
		// 	right: 0;
		// 	bottom: 0;
		// 	height: 6rpx;
		// 	background-color: #2C72FF;
		// }
		// .uni-tab-item-title {
		// 	color: #333333;
		// 	font-size: 32rpx;
		// 	flex-wrap: nowrap;
		// 	white-space: nowrap;
		// }

		// .uni-tab-item-title-active {
		// 	font-size: 32rpx;
		// 	color: #333333;
		// 	font-weight: bolder;
		// }
	}
}
.list-info {
	margin: 0 30rpx;
	padding-bottom: 30rpx;
	.list-swiper{
		height: 1000rpx;
	}
	.data-list{
		background-color: #FFFFFF;
		border-radius: 10rpx;
		padding: 30rpx 20rpx;
		margin-top: 20rpx;
		.data-item{
			.order-info{
				.info-item{
					display: flex;
					font-size: 28rpx;
					color: #333333;
					line-height: 50rpx;
					.key{
						min-width: 150rpx;
						font-size: 28rpx;
						color: #999999;
					}
					.info-imgs{
						display: flex;
						flex-wrap: wrap;
						margin-bottom: 10rpx;
						.img-item{
							width: 120rpx;
							height: 120rpx;
							margin: 2rpx 2rpx 0 0;
						}
					}
				}
				.error{
					color: #FF3737;
				}
			}

			.target-info{
				flex: 1;
				display: flex;
				.img{
					width: 260rpx;
					height: 195rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}
				.top{
					.name{
						font-size: 28rpx;
						font-weight: bolder;
						color: #333333;
					}
					.desc{
						font-size: 28rpx;
						color: #999999;
						margin-top: 10rpx;
					}
				}
				.fee{
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 30rpx;
					.amount{
						font-size: 36rpx;
						color: #FF3737;
					}
				}
			}
		}
	}
}
</style>
